import React,{useEffect} from 'react';
import { 
    StyleSheet,
    Text,
    View,
    BackHandler,
    ToastAndroid
} from 'react-native';
import Stackbar from './features/Stackbar';
import Provider from './features/Context';

let now = 0;

export default function App() {
    useEffect(()=>{
        BackHandler.addEventListener(
            'hardwareBackPress',
            ()=>{
                if(Date.now()-now>2000) {
                    now = Date.now();
                    ToastAndroid.show('确定要退出吗',ToastAndroid.SHORT)
                    return true;
                } else {
                    BackHandler.exitApp()
                }
            }
        )
    },[])

    return (
        <Provider>
            <Stackbar />
        </Provider>
    );
}

const styles = StyleSheet.create({
});
